package com.seabook.store.util;

import java.io.IOException;
import java.util.Properties;

public class PropertyManager {
    
    private static String env = "dev";
    
    private static Properties properties;
    
    public static String getProperty(String key){
        if(null == properties){
            properties = getProperties();
        }
        return properties.getProperty(key);
    }
    
    private static Properties getProperties(){
        properties = new Properties();
        try {
            properties.load(PropertyManager.class.getResourceAsStream(getPropertyFileName()));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return properties;
    }
    
    private static String getPropertyFileName(){
        String filename = "/365buy." + env + ".properties";
        System.out.println(filename);
        return filename;
    }
    
    public static void reload(String env){
        PropertyManager.env = env;
        getProperties();
    }
    
    

}
